QuickTime 3 Reference

Previous | Chapter Top | Chapter Contents | Next

Shape Properties

The properties of a shape object for the most part define the basic geometric characteristics of the shape. Shape objects have properties. Because a shape is an object and not a data structure, the order of the properties is completely arbitrary.

The fill property, which is used for paths, is a value that determines how a shape is filled or framed when drawn. QuickDraw GX provides a number of different ways of filling a shape. For example, a shape might have a solid fill, which indicates that the shape is solid--that is, the entire area enclosed by the sides of the rectangle is included in the shape. Alternatively, a shape might have a framed fill, which indicates that the shape is hollow. The section "Shape Fill," discusses types of shape fill.

Shape Type

The shape type property of a shape object specifies what type of shape the shape object represents. The type used for QuickTime vectors is the path, specified by the gxPathType constant. Its geometry includes any number of separate multiple-point path contours, each contour consisting of straight or curved line segments connecting its points.

Shape Geometry

For a path, the shape type does not contain all the geometric information necessary to define the shape. The geometries of paths contain (x, y) coordinate pairs called geometric points --points that specify the location, dimension, and form of the paths:

There are two possible views of a geometry: as a list of x, y coordinate pairs and as geometric points plotted on a geometric grid. This second way of viewing geometries is used frequently throughout this chapter, as it shows not only the geometric points, but also the implied edges that connect them. Typically, the figures in this chapter do not show the grid, but just the points and edges.

Each geometric point in a geometry has a geometry index --if you consider the geometry as a list of geometric points starting from the first geometric point of the first contour to the last geometric point of the last contour, the geometry index of a particular geometric point is its position in this list.

QuickDraw GX takes into consideration the direction that an edge is pointing in a number of circumstances:

Shape Fill

Each path object has a fill property. This property specifies how QuickDraw GX interprets the geometry of the shape: how the shape is drawn, how the shape is hit-tested, and how certain geometric operations, like intersection or union, interpret the shape. There are two basic types of shape fills:

Note that framed fill, hollow fill, and solid fill are alternative names for open-frame fill, closed-frame fill, and even-odd fill, respectively, and that both inverse solid fill and inverse fill are alternate names for inverse even-odd fill.

A path can have any type of shape fill.

Figure 4 shows an example of a contour and how QuickDraw GX might draw it with a framed fill and with a solid fill.

Figure 4 Framed shapes versus solid shapes

QuickDraw GX actually provides seven types of shape fills:

Figure 5 shows these shape fills and the effect they have on three sample geometries.

Figure 5 The various shape fills and examples of their effects

The no-fill shape fill specifies that QuickDraw GX should not draw the shape. You can use this shape fill to hide a shape. You can specify the no-fill shape fill for any shape type.

The open-frame shape fill specifies that QuickDraw GX should draw a shape as a connected set of edges. The closed-frame shape fill indicates that QuickDraw GX should also connect the last geometric point of a contour to the first geometric point of that contour.

The even-odd shape fill and the winding shape fill indicate that QuickDraw GX should interpret the shape as a solid area--the edges of the shape represent the boundaries of the area. These two shape fills differ in the algorithm they use to determine what area to include in the shape.

The even-odd shape fill indicates that QuickDraw GX should use the even-odd rule to determine what area lies inside a shape. As QuickDraw GX scans a shape horizontally, it fills the area between every other pair of edges, as shown in Figure 7 .

Figure 6 Even-odd and winding fills

The winding shape fill indicates that QuickDraw GX should use the winding-number rule to determine what area lies inside a shape. As QuickDraw GX scans a shape horizontally, it increments a counter the first time it crosses an edge of the shape. It also notices whether the contour was directed up or down at that edge. As QuickDraw GX continues to scan the shape horizontally, every time it crosses another edge pointed in the same direction (up or down), it increments the counter, and when it crosses an edge pointing in the opposite direction (down or up), it decrements the counter. Wherever along the horizontal scan line the counter is not zero, QuickDraw GX fills the area, as is shown in Figure 7 .

Figure 7 The even-odd rule and winding-number rule algorithms

The inverse even-odd shape fill indicates the inverse of the even-odd shape fill, as shown in Figure 8 .

Figure 8 The inverse even-odd shape fill

Similarly, the inverse winding shape fill indicates the inverse of the winding shape fill.

The shape fill does more than affect the way a shape is drawn; it affects the fundamental behavior of a shape. Two shapes with the same geometry that have different shape fills can exhibit vastly different geometric behaviors. For example, the shape fill can affect

Table 2 lists the defined constants for shape fill and describes what each one means. (Note that some shape fills have two or more equivalent names.) The constants are defined in the gxShapeFills enumeration.

Table 2 Shape fills 

Constant

Value

Explanation

gxNoFill

0

No fill--the shape is not filled at all. QuickDraw GX does not draw a shape with this shape fill and you may not perform geometric operations on it. You can use this shape fill to temporarily hide shapes or to prevent parts of a picture from drawing.

gxOpenFrameFill

1

Open-frame fill--the shape is outlined instead of filled. With this shape fill, QuickDraw GX interprets the shape as a connected series of straight or curved lines from the starting point of the shape geometry to the ending point
(but not back to the starting point again).

gxFrameFill

1

Framed fill (same as gxOpenFrameFill ).

gxClosedFrameFill

2

Closed-frame fill--the shape is outlined instead of filled. As with the open-frame fill, QuickDraw GX interprets the shape as a series of lines (or curves) from the starting point of the shape geometry to the ending point. However, in this case, QuickDraw GX also includes a line (or curve) from the ending point to the starting point, thus closing the contour.

gxHollowFill

2

Hollow fill (same as gxClosedFrameFill ).

gxEvenOddFill

3

Even-odd fill--the shape is filled using
the even-odd rule. See Figure 6 for an
illustration of this rule.

gxSolidFill

3

Solid fill (same as gxEvenOddFill ).

gxWindingFill

4

Winding fill--the shape is filled using
the winding-number rule. See Figure 6 for an illustration of this rule.

gxInverseEvenOddFill

5

Inverse even-odd fill--the shape is filled in
an opposite manner from the even-odd rule; everything not filled using the even-odd rule is filled using this rule.

gxInverseSolidFill

5

Inverse solid fill
(same as gxInverseEvenOddFill ).

gxInverseFill

5

Inverse fill
(same as gxInverseEvenOddFill ).

gxInverseWindingFill

6

Inverse winding fill--the shape is filled using the winding-number rule and then inverted.


© 1997 Apple Computer, Inc.

Previous | Chapter Top | Chapter Contents | Next